package com.laboratory.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.laboratory.listener.CourseListener;
import com.laboratory.mapper.CourseMapper;
import com.laboratory.model.dto.course.CourseQueryDto;
import com.laboratory.model.entity.Course;
import com.laboratory.model.vo.course.CourseEeVo;
import com.laboratory.model.vo.course.CourseVo;
import com.laboratory.service.CourseService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course>
        implements CourseService {

    @Override
    public List<CourseVo> getAll(Integer pIndex, Integer pSize, CourseQueryDto courseQueryDto) {
        PageHelper.startPage(pIndex, pSize);
        return baseMapper.getAll(courseQueryDto);
    }


    @Override
    public void importCourse() {
        EasyExcel.write("D:\\课程信息.xlsx", CourseEeVo.class).sheet("课程").doWrite(baseMapper.getExportDate());

    }

    @Override
    public void joinCourse() {
        EasyExcel.read("D:\\课程信息.xlsx", CourseEeVo.class, new CourseListener(baseMapper)).sheet("课程").doRead();
    }
}




